/*
 * @Descripttion:
 * @version:
 * @Author: ChenXiang
 * @Date: 2021-07-24 22:52:52
 * @LastEditors: ChenXiang
 * @LastEditTime: 2021-08-19 21:35:14
 */
import React, { useEffect } from "react";
import Form, { Field } from "@/components/Form";
import { Input, Button } from "antd";

export default function MyRc(props) {
  // var a = [{ name: 'cx' }]
  // const [demo] = a;
  // console.log(demo)//{name:cx}
  const [form] = Form.useForm();
  const onFinish = (val) => {
    console.log("onFinish", val);
  };
  const onFinishFailed = (val) => {
    console.log("onFinishFailed", val);
  };

  useEffect(() => {
    form.setFieldValue({
      password: "qq"
    });
  }, []);

  return (
    <div>
      <Form form={form} onFinish={onFinish} onFinishFailed={onFinishFailed}>
        <Field
          name="username"
          rules={[
            {
              required: true,
              message: "Please input your Username!"
            }
          ]}
        >
          <Input placeholder="Username" />
        </Field>
        <Field
          name="password"
          rules={[
            {
              required: true,
              message: "Please input your Password!"
            }
          ]}
        >
          <Input type="password" placeholder="Password" />
        </Field>

        <Button
          onClick={() => {
            form.submit();
          }}
          className="login-form-button"
        >
          Log in
        </Button>
      </Form>
    </div>
  );
}
